VERSION 5.00
Object = "{8E27C92E-1264-101C-8A2F-040224009C02}#7.0#0"; "MSCAL.OCX"
Begin VB.Form frmTDAdd 
   BackColor       =   &H00FFFFFF&
   Caption         =   "TD Shipment"
   ClientHeight    =   5865
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11550
   Icon            =   "frmTDAdd.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   5865
   ScaleWidth      =   11550
   StartUpPosition =   1  'CenterOwner
   Begin VB.TextBox f1123 
      Enabled         =   0   'False
      Height          =   315
      Left            =   2100
      Locked          =   -1  'True
      TabIndex        =   51
      Top             =   180
      Width           =   3015
   End
   Begin VB.Timer timerLoad 
      Enabled         =   0   'False
      Interval        =   200
      Left            =   225
      Top             =   1035
   End
   Begin VB.ComboBox cboIOR 
      Height          =   315
      Left            =   8400
      Sorted          =   -1  'True
      TabIndex        =   23
      Top             =   4035
      Width           =   3015
   End
   Begin VB.ComboBox cboReturn 
      Height          =   315
      IntegralHeight  =   0   'False
      ItemData        =   "frmTDAdd.frx":1272
      Left            =   8400
      List            =   "frmTDAdd.frx":1274
      Sorted          =   -1  'True
      TabIndex        =   22
      Top             =   3060
      Width           =   3015
   End
   Begin VB.ComboBox cboBrokerID 
      Height          =   315
      Left            =   8550
      TabIndex        =   19
      Top             =   1410
      Width           =   2790
   End
   Begin VB.ComboBox f66 
      Height          =   315
      Left            =   8550
      TabIndex        =   20
      Top             =   1785
      Width           =   2790
   End
   Begin VB.TextBox f67 
      Height          =   315
      Left            =   8550
      TabIndex        =   21
      Top             =   2160
      Width           =   1815
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   840
      Left            =   6150
      TabIndex        =   14
      Top             =   960
      Width           =   840
      Begin VB.OptionButton f1502Y 
         BackColor       =   &H00FFFFFF&
         Caption         =   "FTN"
         Height          =   255
         Left            =   0
         TabIndex        =   15
         Top             =   75
         Width           =   690
      End
      Begin VB.OptionButton f1502N 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Other"
         Height          =   255
         Left            =   0
         TabIndex        =   18
         Top             =   450
         Width           =   765
      End
   End
   Begin VB.ComboBox f1546 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":1276
      Left            =   8550
      List            =   "frmTDAdd.frx":1280
      Locked          =   -1  'True
      TabIndex        =   16
      Text            =   "1"
      Top             =   1035
      Width           =   990
   End
   Begin VB.TextBox f1503 
      Height          =   315
      Left            =   10200
      TabIndex        =   17
      Top             =   1035
      Width           =   1140
   End
   Begin VB.TextBox f25 
      Height          =   315
      Left            =   2100
      TabIndex        =   13
      Top             =   4860
      Width           =   3015
   End
   Begin VB.CheckBox f1484 
      BackColor       =   &H00FFFFFF&
      Height          =   315
      Left            =   2100
      TabIndex        =   2
      Top             =   1785
      Value           =   1  'Checked
      Width           =   240
   End
   Begin VB.CheckBox f113 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Create Consolidated Commercial Invoice"
      Height          =   315
      Left            =   2100
      TabIndex        =   6
      Top             =   2610
      Value           =   1  'Checked
      Width           =   3465
   End
   Begin VB.TextBox f119 
      Height          =   315
      Left            =   2100
      TabIndex        =   5
      Top             =   2235
      Width           =   1365
   End
   Begin MSACAL.Calendar Calendar1 
      Height          =   315
      Left            =   3675
      TabIndex        =   28
      TabStop         =   0   'False
      Top             =   1035
      Visible         =   0   'False
      Width           =   315
      _Version        =   524288
      _ExtentX        =   556
      _ExtentY        =   556
      _StockProps     =   1
      BackColor       =   16777215
      Year            =   2004
      Month           =   2
      Day             =   9
      DayLength       =   1
      MonthLength     =   2
      DayFontColor    =   0
      FirstDay        =   1
      GridCellEffect  =   1
      GridFontColor   =   10485760
      GridLinesColor  =   -2147483632
      ShowDateSelectors=   -1  'True
      ShowDays        =   -1  'True
      ShowHorizontalGrid=   -1  'True
      ShowTitle       =   0   'False
      ShowVerticalGrid=   -1  'True
      TitleFontColor  =   10485760
      ValueIsNull     =   -1  'True
      BeginProperty DayFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.26
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty GridFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty TitleFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   12.01
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.TextBox f1358 
      Height          =   315
      Left            =   2100
      TabIndex        =   12
      Top             =   4485
      Width           =   3015
   End
   Begin VB.ComboBox f72 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":12AC
      Left            =   2100
      List            =   "frmTDAdd.frx":12C2
      TabIndex        =   9
      Top             =   3735
      Width           =   3015
   End
   Begin VB.TextBox f24 
      Height          =   315
      Left            =   2100
      TabIndex        =   0
      Top             =   1035
      Width           =   1065
   End
   Begin VB.CommandButton cmdContinue 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Continue"
      Height          =   315
      Left            =   300
      MaskColor       =   &H00E0E0E0&
      Style           =   1  'Graphical
      TabIndex        =   24
      Top             =   5310
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   315
      Left            =   10200
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   25
      Top             =   5160
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.TextBox f1483 
      BackColor       =   &H00FFFFFF&
      Height          =   315
      Left            =   2100
      TabIndex        =   1
      Text            =   "XXXX"
      Top             =   1410
      Width           =   1515
   End
   Begin VB.ComboBox f75 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":13A2
      Left            =   2100
      List            =   "frmTDAdd.frx":13AC
      TabIndex        =   8
      Text            =   "LBS"
      Top             =   3360
      Width           =   840
   End
   Begin VB.ComboBox f70 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":13BA
      Left            =   2100
      List            =   "frmTDAdd.frx":13C4
      TabIndex        =   10
      Text            =   "1"
      Top             =   4110
      Width           =   1065
   End
   Begin VB.TextBox f71 
      Height          =   315
      Left            =   4050
      TabIndex        =   11
      Top             =   4110
      Width           =   1890
   End
   Begin VB.ComboBox f68 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":13F0
      Left            =   2100
      List            =   "frmTDAdd.frx":13F2
      TabIndex        =   7
      Text            =   "USD"
      Top             =   2985
      Width           =   840
   End
   Begin VB.TextBox f1500 
      Height          =   315
      Left            =   4575
      TabIndex        =   4
      Top             =   1785
      Width           =   1365
   End
   Begin VB.ComboBox f1498 
      Height          =   315
      ItemData        =   "frmTDAdd.frx":13F4
      Left            =   2925
      List            =   "frmTDAdd.frx":13FE
      Locked          =   -1  'True
      TabIndex        =   3
      Text            =   "1"
      Top             =   1785
      Width           =   990
   End
   Begin VB.Timer timerAutoOpen 
      Enabled         =   0   'False
      Interval        =   200
      Left            =   240
      Top             =   2640
   End
   Begin VB.Label lblf1123 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Master Shipment ID:"
      Height          =   315
      Left            =   225
      TabIndex        =   52
      Top             =   180
      Width           =   1750
   End
   Begin VB.Line Line1 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      Index           =   3
      X1              =   6150
      X2              =   11370
      Y1              =   3735
      Y2              =   3735
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Importer ID:"
      Height          =   315
      Index           =   10
      Left            =   6900
      TabIndex        =   50
      Top             =   4035
      Width           =   1365
   End
   Begin VB.Label Label5 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Importer of Record"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   315
      Left            =   6150
      TabIndex        =   49
      Top             =   3735
      Width           =   2115
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Return To:"
      Height          =   315
      Index           =   9
      Left            =   6900
      TabIndex        =   48
      Top             =   3060
      Width           =   1365
   End
   Begin VB.Line Line1 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      Index           =   2
      X1              =   6150
      X2              =   11370
      Y1              =   2760
      Y2              =   2760
   End
   Begin VB.Label Label4 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Return Information"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   315
      Left            =   6150
      TabIndex        =   47
      Top             =   2760
      Width           =   2115
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Broker Phone:"
      Height          =   315
      Index           =   8
      Left            =   6975
      TabIndex        =   46
      Top             =   2085
      Width           =   1365
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Broker Name:"
      Height          =   315
      Index           =   7
      Left            =   7050
      TabIndex        =   45
      Top             =   1785
      Width           =   1365
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Broker ID:"
      Height          =   315
      Index           =   6
      Left            =   7050
      TabIndex        =   44
      Top             =   1410
      Width           =   1365
   End
   Begin VB.Line Line1 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      Index           =   1
      X1              =   6150
      X2              =   11325
      Y1              =   735
      Y2              =   735
   End
   Begin VB.Label Label3 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Broker Information"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   315
      Left            =   6150
      TabIndex        =   43
      Top             =   735
      Width           =   2115
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Acct #:"
      Height          =   315
      Index           =   7
      Left            =   9525
      TabIndex        =   42
      Top             =   1035
      Width           =   615
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Payment Type:"
      Height          =   315
      Index           =   6
      Left            =   7050
      TabIndex        =   41
      Top             =   1035
      Width           =   1440
   End
   Begin VB.Label lblf25 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Reference:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   225
      TabIndex        =   40
      Top             =   4860
      Width           =   1750
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Type:"
      Height          =   315
      Index           =   5
      Left            =   2325
      TabIndex        =   39
      Top             =   1785
      Width           =   465
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Total customs value:"
      Height          =   315
      Index           =   4
      Left            =   225
      TabIndex        =   38
      Top             =   2235
      Width           =   1750
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Currency:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   2
      Left            =   225
      TabIndex        =   37
      Top             =   2985
      Width           =   1750
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "FedEx linehaul payment:"
      Height          =   315
      Index           =   19
      Left            =   225
      TabIndex        =   36
      Top             =   1785
      Width           =   1750
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Acct #:"
      Height          =   315
      Index           =   0
      Left            =   3900
      TabIndex        =   35
      Top             =   1785
      Width           =   615
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Acct #:"
      Height          =   315
      Index           =   1
      Left            =   3225
      TabIndex        =   34
      Top             =   4110
      Width           =   690
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Duty/Tax Pay Type:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   23
      Left            =   225
      TabIndex        =   33
      Top             =   4110
      Width           =   1750
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "SCAC:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   0
      Left            =   225
      TabIndex        =   32
      Top             =   1410
      Width           =   1750
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Weight Type:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   3
      Left            =   225
      TabIndex        =   31
      Top             =   3360
      Width           =   1750
   End
   Begin VB.Label lblCommodity 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Terms of Sale:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   0
      Left            =   225
      TabIndex        =   30
      Top             =   3735
      Width           =   1750
   End
   Begin VB.Label lblf20 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Export Permit #:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   2
      Left            =   225
      TabIndex        =   29
      Top             =   4485
      Width           =   1750
   End
   Begin VB.Image Image1 
      Height          =   315
      Left            =   3300
      Picture         =   "frmTDAdd.frx":142A
      Stretch         =   -1  'True
      Top             =   1035
      Width           =   315
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Ship Date:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Index           =   44
      Left            =   225
      TabIndex        =   27
      Top             =   1035
      Width           =   1750
   End
   Begin VB.Label Label9 
      BackColor       =   &H00FFFFFF&
      BackStyle       =   0  'Transparent
      Caption         =   "Shipment Information"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   315
      Left            =   225
      TabIndex        =   26
      Top             =   735
      Width           =   2115
   End
   Begin VB.Line Line1 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      Index           =   0
      X1              =   225
      X2              =   5445
      Y1              =   735
      Y2              =   735
   End
End
Attribute VB_Name = "frmTDAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'
' 2005-04-21, JFW, Organize all TD master fields
' 2007-01-22, JFW, New setup and registry entry for TD Linehaul default value.
'

Option Explicit

Public tdBroker As Collection
Public tdIOR As Collection
Public tdReturn As Collection
Dim mblnLoaded As Boolean
Dim m_dtTDDate As Date
'


Public Sub AutoOpen(dtTDDate As Date)

    Me.Show 0, g_frmTD
    m_dtTDDate = dtTDDate
    f24 = dtTDDate
    Me.Show 0
    timerAutoOpen.Enabled = True
    
End Sub


'---------------------------------------------------------------------------------------
' Procedure : LoadTDAddForm()
' DateTime  : 11/18/2004
' Purpose   : Gets TD info from database and populates TD Add form fields.
' Call from : f1355_Click(), Form_Activate
'---------------------------------------------------------------------------------------
'
Private Sub LoadTDAddForm(ByVal p_strMasterShipmentID As String)

    Dim i As Long
    Dim tdControl As Control
    Dim strQuery As String
    Dim rsTD As New ADODB.Recordset
    
    On Error GoTo EH
    g_strErrorLocation = "frmTDAdd.LoadTDAddForm"
    
    ' Load TD master for confirmation
    If p_strMasterShipmentID <> "" Then
        strQuery = "SELECT * FROM TD WHERE g_str1123 = " & SingleQuotes(p_strMasterShipmentID) _
            & " AND MAWB = 1"
    Else
        strQuery = "SELECT MAX(ProcessTime) as MaxProcessTime FROM TD WHERE MAWB = 1 AND Status <> 'Deleted' AND TDStatus <> 'Deleted' "
        rsTD.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
        If Not rsTD.BOF Then
            If Not IsNull(rsTD!MaxProcessTime) Then
                
                If GetClientDatabaseType = "Access" Then
                    strQuery = "SELECT * FROM TD WHERE ProcessTime = #" & rsTD!MaxProcessTime & "#"
                Else
                    strQuery = "SELECT * FROM TD WHERE ProcessTime = '" & rsTD!MaxProcessTime & "'"
                End If

                rsTD.Close
            Else
                strQuery = ""
            End If
        End If
    End If
    If strQuery <> "" Then
        rsTD.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
        If Not rsTD.BOF Or Not rsTD.EOF Then
            For Each tdControl In Me.Controls
                Select Case tdControl.name
                Case "f1123"
                    If g_blnTDConfirm Then
                        tdControl.Text = rsTD.Fields("g_str1123").Value
                    End If
                Case "cboIOR"
                    tdControl.Text = rsTD.Fields("IORID").Value
                    Call cboIOR_LostFocus
                Case "cboReturn"
                    tdControl.Text = rsTD.Fields("ReturnAddressID").Value
                    Call cboReturn_LostFocus
                Case "f24"
                    If p_strMasterShipmentID <> "" Then
                        tdControl.Text = CDate(Format(rsTD.Fields("g_str24").Value, "0000-00-00"))
                    End If
                Case "f113", "f1484"
                    tdControl.Value = IIf(rsTD.Fields(tdControl.name).Value = "Y", 1, False)
                Case "f1502Y"
                    tdControl.Value = IIf(rsTD.Fields("f1502").Value = "Y", 1, False)
                Case "f1502N"
                    tdControl.Value = IIf(rsTD.Fields("f1502").Value = "N", 1, False)
                Case Else
                    For i = 0 To rsTD.Fields.Count - 1
                        If tdControl.name = rsTD.Fields(i).name _
                        Or tdControl.name = Replace(rsTD.Fields(i).name, "g_str", "f") Then
                            tdControl.Text = rsTD.Fields(i).Value
                        End If
                    Next i
                End Select
            Next tdControl
        End If
    End If
    
Release:
    On Error Resume Next
    If rsTD.State = adStateOpen Then rsTD.Close
    Set rsTD = Nothing
    Exit Sub

EH:
    MsgBox Err.Description, vbCritical, "frmTDAdd.LoadTDAddForm"
    Resume Release
    Resume
End Sub


Private Sub cboBrokerID_KeyPress(KeyAscii As Integer)

    Call SearchCombo(cboBrokerID, KeyAscii)
    
End Sub

Private Sub cboBrokerID_LostFocus()
    
    On Error GoTo EH
    Dim i As Long
    Dim strQuery As String
    Dim rsCustomer As New ADODB.Recordset
    g_strErrorLocation = "frmTDAdd:cboBrokerID_LostFocus"
    
    If cboBrokerID <> "" Then
        strQuery = "SELECT * FROM AddressBook WHERE CustID = " & SingleQuotes(cboBrokerID)
        rsCustomer.Open strQuery, g_connFSMSClient, adOpenKeyset, adLockOptimistic
        If Not rsCustomer.EOF Then
            If IsNull(rsCustomer!f11) Or rsCustomer!f11 = "" Then
                f66 = rsCustomer!f12
            Else
                f66 = rsCustomer!f11
            End If
            f67 = rsCustomer!f18
        End If
        Set tdBroker = New Collection
        For i = 0 To rsCustomer.Fields.Count - 1
            tdBroker.Add rsCustomer.Fields(i).Value, rsCustomer.Fields(i).name
        Next i
    End If

Release:
    If rsCustomer.State = adStateOpen Then rsCustomer.Close
    Set rsCustomer = Nothing
    Exit Sub
    
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release

End Sub



Private Sub cboIOR_KeyPress(KeyAscii As Integer)
    
    Call SearchCombo(cboIOR, KeyAscii)

End Sub

Private Sub cboIOR_LostFocus()

    On Error GoTo EH
    Dim i As Long
    Dim strQuery As String
    Dim rsCustomer As New ADODB.Recordset
    g_strErrorLocation = "frmTDAdd:cboIOR_LostFocus"
    
    If cboIOR <> "" Then
        strQuery = "SELECT * FROM AddressBook WHERE CustID = " & SingleQuotes(cboIOR)
        rsCustomer.Open strQuery, g_connFSMSClient, adOpenKeyset, adLockOptimistic
        If Not rsCustomer.EOF Then
            Set tdIOR = New Collection
            For i = 0 To rsCustomer.Fields.Count - 1
                tdIOR.Add rsCustomer.Fields(i).Value, rsCustomer.Fields(i).name
            Next i
        End If
    End If

Release:
    If rsCustomer.State = adStateOpen Then rsCustomer.Close
    Set rsCustomer = Nothing
    Exit Sub
    
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release

End Sub

Private Sub cboReturn_KeyPress(KeyAscii As Integer)

    Call SearchCombo(cboReturn, KeyAscii)

End Sub

Private Sub cboReturn_LostFocus()

    On Error GoTo EH
    Dim i As Long
    Dim strQuery As String
    Dim rsCustomer As New ADODB.Recordset
    g_strErrorLocation = "frmTDAdd:cboReturn_LostFocus"
    
    If cboReturn <> "" Then
        strQuery = "SELECT * FROM AddressBook WHERE CustID = " & SingleQuotes(cboReturn)
        rsCustomer.Open strQuery, g_connFSMSClient, adOpenKeyset, adLockOptimistic
        If Not rsCustomer.EOF Then
            Set tdReturn = New Collection
            For i = 0 To rsCustomer.Fields.Count - 1
                tdReturn.Add rsCustomer.Fields(i).Value, rsCustomer.Fields(i).name
            Next i
        End If
    End If

Release:
    If rsCustomer.State = adStateOpen Then rsCustomer.Close
    Set rsCustomer = Nothing
    Exit Sub
    
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release

End Sub

Private Sub cmdCancel_Click()
    On Error Resume Next
    g_blnTDConfirm = False
    g_blnTDCreate = False
    Unload Me
    Set g_frmTDAdd = Nothing
    g_frmTD.SetFocus
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdContinue_Click()
' DateTime  : 10/25/2004
' Purpose   : Assigns values to globals vars then builds and sends Create transaction.
'---------------------------------------------------------------------------------------
'
Private Sub cmdContinue_Click()
    
    g_str50 = tdReturn("f50")
    g_str24 = Format(CDate(f24), "yyyymmdd")
    g_dteTDDate = CDate(f24)
    g_str68 = f68
    g_str70 = Left(f70, 1)
    g_str71 = f71
    g_str72 = Left(f72, 1)
    ' frmMsgBox.ShowMessage "See TDAdd field 74", 10000
    'g_str74 = tdReturn("f50")
    g_str75 = f75
    g_str113 = IIf(f113, "Y", "N")
    g_str1358 = f1358
    
    g_blnTDInProgress = True
    
    If g_blnTDConfirm Then
        Call SendData(BuildTDConfirmTrans(g_str498, g_strTDOpenShip))
        g_blnTDConfirm = False
        
    ElseIf g_blnTDCreate Then
        DebugPrint "Continue.SendData, trans " & BuildTDCreateTrans
        Call SendData(BuildTDCreateTrans)
        g_blnTDCreate = False
    
    End If

End Sub


Private Sub f1358_Change()
    If g_blnTDConfirm Then
        f1358.BackColor = IIf(f1358 = "", &HC0E0FF, &HFFFFFF)
    End If
End Sub


Private Sub f1483_Validate(Cancel As Boolean)

    g_clsReg.SetRegistryValue "SCAC", f1483, REG_SZ
    
End Sub

Private Sub f1502Y_Click()

    If f1502Y Then
        f66 = "FTN"
        f67 = "1235551234"
    End If
    
End Sub

Private Sub f66_KeyPress(KeyAscii As Integer)
    Call SearchCombo(f66, KeyAscii)
End Sub

Private Sub f66_LostFocus()
    
    On Error GoTo EH
    Dim strQuery As String
    Dim rsCustomer As New ADODB.Recordset
    g_strErrorLocation = "frmTDAdd:f66_LostFocus"
    
    If f66 <> "" Then
        strQuery = "SELECT * FROM AddressBook WHERE f11 = " & SingleQuotes(f66)
        rsCustomer.Open strQuery, g_connFSMSClient, adOpenKeyset, adLockOptimistic
        If Not rsCustomer.EOF Then
            cboBrokerID.Text = rsCustomer!CustID
            If Not IsNull(rsCustomer!f18) Or rsCustomer!f18 <> "" Then
                f67 = rsCustomer!f18
            End If
        End If
    End If

Release:
    If rsCustomer.State = adStateOpen Then rsCustomer.Close
    Set rsCustomer = Nothing
    Exit Sub
    
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release

End Sub

'---------------------------------------------------------------------------------------
' Procedure : f72_Change()
' DateTime  : 10/25/2004
' Purpose   : Calls a routine to populate the entire text of Terms of Sale.
'---------------------------------------------------------------------------------------
'
Private Sub f72_Change()
    If Len(f72) >= 1 Then
        Call SetComboSelection(f72, f72)
    End If
End Sub

Private Sub Form_Activate()
    
    If Not mblnLoaded Then
        timerLoad.Enabled = True
    End If
    
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 10/25/2004
' Purpose   : Initial form settings...
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()

    Call LoadCurrencies(f68)
    'f70.ListIndex = 0
    f72.ListIndex = 0
    'f75.ListIndex = 0
    f24.Text = Date
    Calendar1.Today
    Calendar1.Height = 2295 'Ship date - Ship Tab
    Calendar1.Width = 3015
    f1500 = frmSetup.f10
    f71 = frmSetup.f10
    f1503 = frmSetup.f10
    f1483 = g_clsReg.GetRegistryValue("SCAC", 0)
    f1484 = g_clsReg.GetRegistryValue("TDLinehaul", 0)
    
End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : f70_Change()
' DateTime  : 10/25/2004
' Purpose   : Calls a routine to populate the entire text of selected payment type.
'---------------------------------------------------------------------------------------
'
Private Sub f70_Change()
    If Len(f70) >= 1 Then
        Call SetComboSelection(f70, f70)
    End If
End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : f70_Click()
' DateTime  : 11/18/2004
' Purpose   : If Bill 3rd party selected for Duty/Taxes payor highlight Duty/taxes acct#
'             field and set focus to it.
'---------------------------------------------------------------------------------------
'
Private Sub f70_Click()
    On Error GoTo EH
    g_strErrorLocation = "frmTDAdd:f70_Click"
    
    Select Case Left(f70, 1)
        Case "1"
            f71.Enabled = False
            f71 = ""
        Case "2"
            f71.Enabled = True
            f71.BackColor = &HFFFFFF
        Case "3"
            f71.Enabled = True
            f71.BackColor = &HC0E0FF
            f71.SetFocus
    End Select
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub

'---------------------------------------------------------------------------------------
' Procedure : f71_Change()
' DateTime  : 10/25/2004
' Purpose   : Acct# is numeric with max length of 9
'---------------------------------------------------------------------------------------
'
Private Sub f71_Change()
    On Error GoTo EH
    g_strErrorLocation = "frmTDAdd:f20_Change"
    
    f71.BackColor = &HFFFFFF
    Call NumericOnly(f71, False)
    Call CheckLength(f71, 9)
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : f71_LostFocus()
' DateTime  : 10/25/2004
' Purpose   : Validate Billing acct# and give error if not valid. If blank, set acct#
'             back to Bill Shipper and set focus on Billing Type field.
'---------------------------------------------------------------------------------------
'
Private Sub f71_LostFocus()
    On Error GoTo EH
    g_strErrorLocation = "frmTDAdd:f20_LostFocus"
    
    If Not AcctNumCheckOK(f71) Then
        If f71 = "" Then
            f71.BackColor = &HFFFFFF
            f71.SetFocus
        Else
            MsgBox "Invalid FedEx Account Number", vbExclamation, "Ship Error"
            f71.BackColor = &HC0E0FF
            f71.SetFocus
        End If
    End If
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set g_frmTDAdd = Nothing
End Sub

'---------------------------------------------------------------------------------------
' Module    : Image1_Click()
' DateTime  : 10/25/2004
' Author    : Chris Elwell
' Purpose   : Show the ShipDate calendar
'---------------------------------------------------------------------------------------
'
Private Sub Image1_Click()
    Calendar1.Visible = True
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Calendar1_Click()
' DateTime  : 10/25/2004
' Purpose   : Puts date selected on calendar in ShipDate field.
'---------------------------------------------------------------------------------------
'
Private Sub Calendar1_DblClick()
    f24.Text = Calendar1.Value
    Calendar1.Visible = False
End Sub
'

Private Sub timerAutoOpen_Timer()

    f24.Text = m_dtTDDate
    If mblnLoaded Then
        timerAutoOpen.Enabled = False
        Call cmdContinue_Click
    End If
    
End Sub

Private Sub timerLoad_Timer()

    timerLoad.Enabled = False
    Call LoadAddrLookupCombos(cboBrokerID, cboBrokerID, "CustID")
    Call LoadAddrLookupCombos(f66, f66, "f11")
    Call LoadAddrLookupCombos(cboReturn, cboReturn, "CustID")
    Call LoadAddrLookupCombos(cboIOR, cboIOR, "CustID")
    Call LoadTDAddForm(g_strTDMasterTrkNbr)
    mblnLoaded = True
    DebugPrint "timerLoad_Timer, Done"
    
End Sub
